<?php

function convert_new_line($text) {
	return str_replace(PHP_EOL,"<br>",$text);
}

function to_sjis($text, $escape_eol = TRUE) {
	if ($escape_eol) $text = str_replace(PHP_EOL,"<br>",$text);
	$text = mb_convert_encoding($text, 'sjis', 'utf8');
	return $text;
}

function to_utf($text) {
	$text = mb_convert_encoding($text, 'utf8', 'sjis');
	return $text;
}

function escape_php($text) {
	$text = mberegi_replace("<\\?.*?\\?>", "", $text);
	$text = mberegi_replace("</?form.*?>", "", $text);
	$text = mberegi_replace("(<(input|textarea|select))", "\\0 disabled='disabled'", $text);
	return $text;
}